<?php
session_start();
if(!isset($_SESSION['username'])){
	header("location:../index.php");
}
?>
<link href="../css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
<link href="../css/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="../css/table.css" rel="stylesheet" type="text/css" />

<script src="../js/jquery.min.js" type="text/javascript"></script>
<script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="../js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="../js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="../js/jquery-ui.min.js" type="text/javascript"></script>

<script>	
$(document).ready(function() {
	$( "#datepicker" ).datepicker({ changeYear: true,changeMonth: true,dateFormat: "yy-mm-dd",dayNamesMin: ["Mg", "Sn", "Sl", "Rb", "Km", "Jm", "Sa"],monthNamesShort: ["Jan","Feb","Mar","Apr","Mei","Juni","Juli","Agus","Sept","Okt","Nov","Des"],showAnim: "blind" });
	$( "#datepicker2" ).datepicker({ changeYear: true,changeMonth: true,dateFormat: "yy-mm-dd",dayNamesMin: ["Mg", "Sn", "Sl", "Rb", "Km", "Jm", "Sa"],monthNamesShort: ["Jan","Feb","Mar","Apr","Mei","Juni","Juli","Agus","Sept","Okt","Nov","Des"],showAnim: "blind" });
	$("#formID").validationEngine();
});
</script>

<?php
include "../inc/db.php";
//$id_site=$_GET['id_site'];
if(isset($id_site)){
	$sql="select * from tb_site where id_site='$id_site';";
	$hasil=mysql_query($sql);
	$kolom=mysql_fetch_array($hasil);
}
?>

<title>Data Site</title>
<?php
if(!isset($id_site)){
?>
<h2>FORM INPUT DATA SITE</h2>
<form id="formID" action="siteInputProses.php" method="post">
<?php	
}else{
?>
<h2>FORM EDIT DATA SITE</h2>
<form id="formID" action="siteEditProses.php?id_site=<?php echo $id_site; ?>&nav=<?php echo $nav; ?>" method="post">
<?php
}
?>
<table width="475" class="bordered">
  <tr>
    <td width="146">Nama Site</td>
    <td width="4">:</td>
    <td width="318"><input name="nama_site" type="text" id="nama_site" size="50" class="validate[required]" value="<?php echo $kolom[1]; ?>"/></td>
  </tr>
  <tr>
    <td>Tgl Kontrak</td>
    <td>:</td>
    <td><input type="text" name="tgl_kontrak" id="datepicker" readonly="readonly" value="<?php echo $kolom[2]; ?>"/></td>
  </tr>
  <tr>
    <td>Tgl Habis Kontrak</td>
    <td>:</td>
    <td><input type="text" name="tgl_habis_kontrak" id="datepicker2" readonly="readonly" value="<?php echo $kolom[3]; ?>"/></td>
  </tr>
  <tr>
    <td>Lokasi Site</td>
    <td>:</td>
    <td><textarea name="lokasi_site" id="lokasi_site" class="validate[required]"><?php echo $kolom[4]; ?></textarea></td>
  </tr>
  <tr>
    <td>Kota</td>
    <td>:</td>
    <td>
    <select name="kota" id="kota" class="validate[required]">
      	<option value="">-- Pilih Kota -</option>
        <option value="Bangkalan" <?php if($kolom[5] == "Bangkalan"){ echo "selected='selected'"; } ?>>Bangkalan</option>
        <option value="Banyuwangi" <?php if($kolom[5] == "Banyuwangi"){ echo "selected='selected'"; } ?>>Banyuwangi</option>
        <option value="Blitar" <?php if($kolom[5] == "Blitar"){ echo "selected='selected'"; } ?>>Blitar</option>
        <option value="Bojonegoro" <?php if($kolom[5] == "Bojonegoro"){ echo "selected='selected'"; } ?>>Bojonegoro</option>
        <option value="Bondowoso" <?php if($kolom[5] == "Bondowoso"){ echo "selected='selected'"; } ?>>Bondowoso</option>
        <option value="Gresik" <?php if($kolom[5] == "Gresik"){ echo "selected='selected'"; } ?>>Gresik</option>
        <option value="Jember" <?php if($kolom[5] == "Jember"){ echo "selected='selected'"; } ?>>Jember</option>
        <option value="Jombang" <?php if($kolom[5] == "Jombang"){ echo "selected='selected'"; } ?>>Jombang</option>
        <option value="Kediri" <?php if($kolom[5] == "Kediri"){ echo "selected='selected'"; } ?>>Kediri</option>
        <option value="Lamongan" <?php if($kolom[5] == "Lamongan"){ echo "selected='selected'"; } ?>>Lamongan</option>
        <option value="Lumajang" <?php if($kolom[5] == "Lumajang"){ echo "selected='selected'"; } ?>>Lumajang</option>
        <option value="Madiun" <?php if($kolom[5] == "Madiun"){ echo "selected='selected'"; } ?>>Madiun</option>
        <option value="Magetan" <?php if($kolom[5] == "Magetan"){ echo "selected='selected'"; } ?>>Magetan</option>
        <option value="Malang" <?php if($kolom[5] == "Malang"){ echo "selected='selected'"; } ?>>Malang</option>
        <option value="Mojokerto" <?php if($kolom[5] == "Mojokerto"){ echo "selected='selected'"; } ?>>Mojokerto</option>
        <option value="Nganjuk" <?php if($kolom[5] == "Nganjuk"){ echo "selected='selected'"; } ?>>Nganjuk</option>
        <option value="Ngawi" <?php if($kolom[5] == "Ngawi"){ echo "selected='selected'"; } ?>>Ngawi</option>
        <option value="Pacitan" <?php if($kolom[5] == "Pacitan"){ echo "selected='selected'"; } ?>>Pacitan</option>
        <option value="Pamekasan" <?php if($kolom[5] == "Pamekasan"){ echo "selected='selected'"; } ?>>Pamekasan</option>
        <option value="Pasuruan" <?php if($kolom[5] == "Pasuruan"){ echo "selected='selected'"; } ?>>Pasuruan</option>
        <option value="Ponorogo" <?php if($kolom[5] == "Ponorogo"){ echo "selected='selected'"; } ?>>Ponorogo</option>
        <option value="Probolinggo" <?php if($kolom[5] == "Probolinggo"){ echo "selected='selected'"; } ?>>Probolinggo</option>
        <option value="Sampang" <?php if($kolom[5] == "Sampang"){ echo "selected='selected'"; } ?>>Sampang</option>
        <option value="Sidoarjo" <?php if($kolom[5] == "Sidoarjo"){ echo "selected='selected'"; } ?>>Sidoarjo</option>
        <option value="Situbondo" <?php if($kolom[5] == "Situbondo"){ echo "selected='selected'"; } ?>>Situbondo</option>
        <option value="Sumenep" <?php if($kolom[5] == "Sumenep"){ echo "selected='selected'"; } ?>>Sumenep</option>
        <option value="Surabaya" <?php if($kolom[5] == "Surabaya"){ echo "selected='selected'"; } ?>>Surabaya</option>
        <option value="Trenggalek" <?php if($kolom[5] == "Trenggalek"){ echo "selected='selected'"; } ?>>Trenggalek</option>
        <option value="Tuban" <?php if($kolom[5] == "Tuban"){ echo "selected='selected'"; } ?>>Tuban</option>
        <option value="Tulungagung" <?php if($kolom[5] == "Tulungagung"){ echo "selected='selected'"; } ?>>Tulungagung</option>
    </select>
    </td>
  </tr>
  <tr>
    <td>Keterangan 1</td>
    <td>:</td>
    <td><textarea name="keterangan1" id="keterangan1" class="validate[required]"><?php echo $kolom[6]; ?></textarea></td>
  </tr>
  <tr>
    <td>Keterangan 2</td>
    <td>:</td>
    <td><textarea name="keterangan2" id="keterangan2" class="validate[required]"><?php echo $kolom[7]; ?></textarea></td>
  </tr>
  <tr>
    <td colspan="3"><div align="center">
    <?php
	if(!isset($id_site)){
	?>
    	<input type="submit" name="Submit" value="Input" />
        <input type="reset" name="Submit2" value="Reset" />
        <a href="index.php"><input type="button" name="button" id="button" value="Cancel" /></a>
    <?php	
	}else{
	?>
     	<input type="submit" name="Submit" value="Edit" />
        <input type="reset" name="Submit2" value="Reset" />
        <a href="index.php"><input type="button" name="button" id="button" value="Cancel" /></a>
    <?php
	}
	?>
    </div></td>
    </tr>
</table>
</form>
